package com.headingdata.parameter;

public class MethodTest1 {
    public static void main(String[] args) {
        //打印数组 [12,16,23,45,68]
        int[] arr = {12,16,23,45,68};

        printArray(arr);
        int[] arr1 = null;
        printArray(arr1);
    }

    public static void printArray(int[] arr){
        if (arr == null){
            System.out.println(arr);
            return;
        }
        System.out.print("[");
        for (int i = 0; i < arr.length; i++){
             String statement = i == arr.length - 1 ? String.valueOf(arr[i]) : arr[i] + ",";
             System.out.print(statement);
        }
        System.out.println("]");
    }
}
